package iammry.com.base;

import android.app.Application;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Handler;
import android.os.Looper;

import com.alibaba.sdk.android.feedback.impl.FeedbackAPI;
import com.umeng.message.IUmengRegisterCallback;
import com.umeng.message.PushAgent;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.utils.Log;

import iammry.com.utils.CrashHandler;

/**
 * @author kim
 * @version 1.0
 * @time 上午10:10:10
 * @des
 */
public class BaseApplication extends Application {

    private static Context mContext;
    private static Thread mMainThread;
    private static long mMainTreadId;
    private static Looper mMainLooper;
    private static Handler mHandler;
    public static boolean isShowUpdate;

    public static Handler getHandler() {
        return mHandler;
    }

    public static Context getContext() {
        return mContext;
    }

    public static Thread getMainThread() {
        return mMainThread;
    }

    public static long getMainTreadId() {
        return mMainTreadId;
    }

    public static Looper getMainThreadLooper() {
        return mMainLooper;
    }

    private Typeface typeface;
    private static BaseApplication _instance;

    @Override
    public void onCreate() {
        // 启动本地异常收集
        CrashHandler crashHandler = CrashHandler.instance();
        crashHandler.init();

        // 上下
        mContext = getApplicationContext();

        // 主线
        mMainThread = Thread.currentThread();

        // 主线程Id
        mMainTreadId = android.os.Process.myTid();

        // 主线程Looper对象
        mMainLooper = getMainLooper();

        // 定义

        mHandler = new Handler();

        UMShareAPI.get(this);

        //MobclickAgent.setDebugMode(true);

        PlatformConfig.setWeixin("wxacfc1c0815cbb42c", "99470d96a79214bd4581d6b6c2d05bed");
        PlatformConfig.setQQZone("1105711725", "GvMJVPv8gWbvzeSj");
        //推送代码
        PushAgent mPushAgent = PushAgent.getInstance(this);
        //注册推送服务，每次调用register方法都会回调该接口
        mPushAgent.register(new IUmengRegisterCallback() {

            @Override
            public void onSuccess(String deviceToken) {
                //注册成功会返回device token==
                Log.d("deviceToken=" + deviceToken);
            }

            @Override
            public void onFailure(String s, String s1) {

            }
        });
        //反馈的方法
       FeedbackAPI.init(this, "23546980");
        super.onCreate();
    }

    public static BaseApplication getInstace() {
        return _instance;
    }

    public Typeface getTypeface() {
        return typeface;
    }

    public void setTypeface(Typeface typeface) {
        this.typeface = typeface;
    }

}
